#ifndef  __DSTIN_CFG_H__
#define  __DSTIN_CFG_H__

#ifdef   DSTIN_CFG_GLOBALS
#define  DSTIN_CFG_EXT
#else
#define  DSTIN_CFG_EXT  extern
#endif

/***********************************************************/
/****************** Digital Input define   *****************/
/***********************************************************/
/**
  * @brief   Inputs with external interrupt
  
  * @paramx  EXCV2_HLIMIT-----------------PC6  (I)
  * @paramx  EXCV2_LLIMIT-----------------PD15 (I)
  * @paramx  BVOL_HLIMIT -----------------PD14 (I)
  * @paramx  BVOL_LLIMIT -----------------PD13 (I)
  * @paramx  EXCV_HLIMIT -----------------PD12 (I)
  * @paramx  EXCV_LLIMIT -----------------PD11 (I)
  * @paramx  EXCI_HLIMIT -----------------PD10 (I)
  * @paramx  EXCI_LLIMIT -----------------PD9  (I)
  * @paramx  EXCI2_HLIMIT-----------------PD8  (I)
  * @paramx  EXCI2_LLIMIT-----------------PB15 (I)
  * @paramx  AUX_IN1     -----------------PB14 (I)
  */

/* 原-WORM_GEAR-HLIMIT */
// 现-EXCV2_HLIMIT
#define RCCPeriph_EXCV2_HLIM   RCC_APB2_PERIPH_GPIOC
#define GPIOModeI_EXCV2_HLIM   GPIO_Mode_IPD
#define GPIOSpeed_EXCV2_HLIM   GPIO_INPUT
#define GPIOxPort_EXCV2_HLIM   GPIOC
#define GPIOxBitx_EXCV2_HLIM   GPIO_PIN_6
/* 原-WORM_GEAR-LLIMIT */
// 现-EXCV2_LLIMIT
#define RCCPeriph_EXCV2_LLIM   RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_EXCV2_LLIM   GPIO_Mode_IPD
#define GPIOSpeed_EXCV2_LLIM   GPIO_INPUT
#define GPIOxPort_EXCV2_LLIM   GPIOD
#define GPIOxBitx_EXCV2_LLIM   GPIO_PIN_15

/* BUILD_VOL-HLIMIT */
#define RCCPeriph_BUILD_VOL_HLIM   RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_BUILD_VOL_HLIM   GPIO_Mode_IPD
#define GPIOSpeed_BUILD_VOL_HLIM   GPIO_INPUT
#define GPIOxPort_BUILD_VOL_HLIM   GPIOD
#define GPIOxBitx_BUILD_VOL_HLIM   GPIO_PIN_14
/* BUILD_VOL-LLIMIT */
#define RCCPeriph_BUILD_VOL_LLIM   RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_BUILD_VOL_LLIM   GPIO_Mode_IPD
#define GPIOSpeed_BUILD_VOL_LLIM   GPIO_INPUT
#define GPIOxPort_BUILD_VOL_LLIM   GPIOD
#define GPIOxBitx_BUILD_VOL_LLIM   GPIO_PIN_13
/* EXCV-HLIMIT */
#define RCCPeriph_EXCV_HLIMIT   RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_EXCV_HLIMIT   GPIO_Mode_IPD
#define GPIOSpeed_EXCV_HLIMIT   GPIO_INPUT
#define GPIOxPort_EXCV_HLIMIT   GPIOD
#define GPIOxBitx_EXCV_HLIMIT   GPIO_PIN_12
/* EXCV-LLIMIT */
#define RCCPeriph_EXCV_LLIMIT   RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_EXCV_LLIMIT   GPIO_Mode_IPD
#define GPIOSpeed_EXCV_LLIMIT   GPIO_INPUT
#define GPIOxPort_EXCV_LLIMIT   GPIOD
#define GPIOxBitx_EXCV_LLIMIT   GPIO_PIN_11
/* EXCI-HLIMIT */
#define RCCPeriph_EXCI_HLIMIT   RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_EXCI_HLIMIT   GPIO_Mode_IPD
#define GPIOSpeed_EXCI_HLIMIT   GPIO_INPUT
#define GPIOxPort_EXCI_HLIMIT   GPIOD
#define GPIOxBitx_EXCI_HLIMIT   GPIO_PIN_10
/* EXCI-LLIMIT */
#define RCCPeriph_EXCI_LLIMIT   RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_EXCI_LLIMIT   GPIO_Mode_IPD
#define GPIOSpeed_EXCI_LLIMIT   GPIO_INPUT
#define GPIOxPort_EXCI_LLIMIT   GPIOD
#define GPIOxBitx_EXCI_LLIMIT   GPIO_PIN_9
/* EXCI-HLIMIT2 */
#define RCCPeriph_EXCI2_HLIMIT   RCC_APB2_PERIPH_GPIOD
#define GPIOModeI_EXCI2_HLIMIT   GPIO_Mode_IPD
#define GPIOSpeed_EXCI2_HLIMIT   GPIO_INPUT
#define GPIOxPort_EXCI2_HLIMIT   GPIOD
#define GPIOxBitx_EXCI2_HLIMIT   GPIO_PIN_8
/* EXCI-LLIMIT2 */
#define RCCPeriph_EXCI2_LLIMIT   RCC_APB2_PERIPH_GPIOB
#define GPIOModeI_EXCI2_LLIMIT   GPIO_Mode_IPD
#define GPIOSpeed_EXCI2_LLIMIT   GPIO_INPUT
#define GPIOxPort_EXCI2_LLIMIT   GPIOB
#define GPIOxBitx_EXCI2_LLIMIT   GPIO_PIN_15
/* AUX_IN1 */
#define RCCPeriph_AUX_IN1   RCC_APB2_PERIPH_GPIOB
#define GPIOModeI_AUX_IN1   GPIO_Mode_IPD
#define GPIOSpeed_AUX_IN1   GPIO_INPUT
#define GPIOxPort_AUX_IN1   GPIOB
#define GPIOxBitx_AUX_IN1   GPIO_PIN_14

typedef struct
{
  uint32_t              RCC_APB2Periph;
  GPIO_ModeType         GPIO_Mode;
  GPIO_SpeedType        GPIO_Speed;
  GPIO_Module*          GPIOx;
  uint16_t              GPIO_Pin;
} DstInputsCfg_TypeDef;


/* 限位警告 */
enum
{
    Warn_BUILD_VOL_LLIM,   //建压电机触发最小限位     
    Warn_BUILD_VOL_HLIM,   //建压电机触发最大限位     
    Warn_EXCV_LLIMIT,      //励磁分压电机触发最小限位 
    Warn_EXCV_HLIMIT,      //励磁分压电机触发最大限位 
    Warn_EXCI_LLIMIT,      //励磁分流1电机触发最小限位 
    Warn_EXCI_HLIMIT,      //励磁分流1电机触发最大限位 
    Warn_EXCI2_LLIMIT,     //励磁分流2电机触发最小限位 
    Warn_EXCI2_HLIMIT,     //励磁分流2电机触发最大限位 
    Warn_PF_LLIMIT,        //相位或有功调节电机触发最小限位
    Warn_PF_HLIMIT,        //相位或有功调节电机触发最大限位
    Warn_EXCV2_LLIMIT,     //励磁分压电机2触发最小限位 
    Warn_EXCV2_HLIMIT,     //励磁分压电机2触发最大限位 
};

/* Bit and Port Order for Digital Inputs */
#define DstInputsOrd_EXCV2_HLIMIT               0
#define DstInputsOrd_EXCV2_LLIMIT               1
#define DstInputsOrd_BVOL_HLIMIT                2
#define DstInputsOrd_BVOL_LLIMIT                3
#define DstInputsOrd_EXCV_HLIMIT                4
#define DstInputsOrd_EXCV_LLIMIT                5
#define DstInputsOrd_EXCI_HLIMIT                6
#define DstInputsOrd_EXCI_LLIMIT                7
#define DstInputsOrd_EXCI2_HLIMIT               8
#define DstInputsOrd_EXCI2_LLIMIT               9
#define DstInputsOrd_AUX_IN1                    10
#define DstInputsOrd_TOTNum                     (DstInputsOrd_AUX_IN1+1)

DSTIN_CFG_EXT const DstInputsCfg_TypeDef DstInputsCfgTable[DstInputsOrd_TOTNum];
DSTIN_CFG_EXT const OS_FLAGS OSDSTINFlagsTimingTable[DstInputsOrd_TOTNum];
#endif